<template>
  <div class="tag-history tag-scrollbar">
    <tag-content-header refresh @toolFun="toolFun" :settingData="columns">
      <template #title>
        <span>变更历史</span>
      </template>
    </tag-content-header>
    <tag-table
      ref="table"
      @refresh="getList"
      :data="dataList"
      :loading="loading"
      :columns="columns"
      :params="params"
      :total="totalSize"
    >
      <template #modifierNnm="{ scope }">
        {{ $name(scope.row, 'modifierNnm', 'modifierNm') }}
      </template>
    </tag-table>
  </div>
</template>

<script>
export default {
  props: {
    assetId: {
      type: String,
      required: true,
      default: ''
    }
  },
  data() {
    return {
      loading: false,
      dataList: [],
      columns: [
        {
          show: true,
          label: '变更人',
          prop: 'modifierNnm',
          search: true,
          searchKey: ''
        },
        {
          show: true,
          label: '变更时间',
          prop: 'modifyTm',
          search: true,
          searchKey: '',
          align: 'center'
        },
        {
          show: true,
          label: '变更项',
          prop: 'modifyItem',
          align: 'center'
        },
        {
          show: true,
          label: '变更模块',
          prop: 'modifyModuleNm',
          dot: {
            基本信息: '#4e5aa4',
            来源表信息: '#7ac7c1',
            负责人信息: '#8ac0ee'
          },
          align: 'center'
        },
        {
          show: true,
          label: '变更前',
          prop: 'modifyBef',
          align: 'center'
        },
        {
          show: true,
          label: '变更后',
          prop: 'modifyAft',
          align: 'center'
        },
        {
          show: true,
          label: '备注',
          prop: 'cmntStr',
          align: 'center'
        }
      ],
      params: {
        ascs: [],
        descs: [],
        currentPageNum: 1,
        pageSize: 10,
        queryParams: {},
        descPriority: false
      },
      totalSize: 0
    }
  },
  methods: {
    getInfo() {
      this.getList()
    },
    getList() {
      this.loading = true
      this.params.queryParams.tagId = this.assetId
      this.$ajax({
        url: this.$ajax.setUrl('ast/astTagModifyRecord/pageList'),
        method: 'get',
        params: this.$ajax.setParams(this.params)
      }).then(({ data }) => {
        if (data && data.code === '0') {
          this.dataList = data.data.records
          this.totalSize = data.data.totalSize
        } else {
          this.$message.error(data.data || data.msg)
        }
      })
      this.loading = false
    },
    toolFun(operation) {
      switch (operation) {
        case 'refresh':
          // 刷新动作
          this.getList()
          break
      }
    }
  }
}
</script>

<style lang="scss">
.tag-history {
  padding-top: 20px;
  .tag-table {
    .cell {
      line-height: 30px;
    }
    .el-table--border td {
      border-right: none;
      padding-left: 20px;
      padding-right: 20px;
    }
    .el-table--enable-row-hover .el-table__body tr:hover > td {
      position: relative;
      background-color: #dbebfa;
      &:after {
        height: 2px;
        content: '';
        background-color: #4d81ea;
        position: absolute;
        left: 0;
        bottom: 0;
        right: 0;
      }
    }
  }
}
</style>
